SoilGrids is a system for global digital soil mapping that uses state-of-the-art machine learning methods to map the spatial distribution of soil properties across the globe. SoilGrids prediction models are fitted using over 230 000 soil profile observations from a series of environmental covariates.
Maps with a spatial resolution of 250m of the following soil properties are available: pH, soil organic carbon content, bulk density, coarse fragments content, sand content, silt content, clay content, cation exchange capacity (CEC), total nitrogen as well as soil organic carbon density and soil organic carbon stock.
The preview release of SoilGrids (December 2019) can be accessed through the following services:
WMS: swift access for visualization and data overview. WCS: best way to obtain map segments for specific regions in the world and to use SoilGrids as input to other modeling pipelines. WebDAV: download the complete global maps in VRT format.
To download soil data with WMS service and python, first, you need the Python package for client programming with Open Geospatial Consortium (OGC) web service called OWSLib. Install OWSLib with PIP
pip install OWSLib
The next step is to call the WMS service to get the map. Soil profile / Map is categorized with different depth so first, you need to list out all the products you need to download in the python list object as:
#sand content data form 0cm to 200cm wmssand = ['SNDPPT_M_sl1_250m', 'SNDPPT_M_sl2_250m', 'SNDPPT_M_sl3_250m', 'SNDPPT_M_sl4_250m', 'SNDPPT_M_sl5_250m', 'SNDPPT_M_sl6_250m', 'SNDPPT_M_sl7_250m'] #Clay content data form 0cm to 200cm wmsclay = ['CLYPPT_M_sl1_250m', 'CLYPPT_M_sl2_250m', 'CLYPPT_M_sl3_250m', 'CLYPPT_M_sl4_250m', 'CLYPPT_M_sl5_250m', 'CLYPPT_M_sl6_250m', 'CLYPPT_M_sl7_250m'] #pH content data form 0cm to 200cm wmsph = ['PHIHOX_M_sl1_250m', 'PHIHOX_M_sl2_250m', 'PHIHOX_M_sl3_250m', 'PHIHOX_M_sl4_250m', 'PHIHOX_M_sl5_250m', 'PHIHOX_M_sl6_250m', 'PHIHOX_M_sl7_250m', 'PHIKCL_M_sl1_250m', 'PHIKCL_M_sl2_250m', 'PHIKCL_M_sl3_250m', 'PHIKCL_M_sl4_250m', 'PHIKCL_M_sl5_250m', 'PHIKCL_M_sl6_250m', 'PHIKCL_M_sl7_250m'] #Coarse content data form 0cm to 200cm wmscoarse = ['CRFVOL_M_sl1_250m', 'CRFVOL_M_sl2_250m', 'CRFVOL_M_sl3_250m', 'CRFVOL_M_sl4_250m', 'CRFVOL_M_sl5_250m', 'CRFVOL_M_sl6_250m', 'CRFVOL_M_sl7_250m'] #Slit content data form 0cm to 200cm wmsslit = ['SLTPPT_M_sl1_250m', 'SLTPPT_M_sl2_250m', 'SLTPPT_M_sl3_250m', 'SLTPPT_M_sl4_250m', 'SLTPPT_M_sl5_250m', 'SLTPPT_M_sl6_250m', 'SLTPPT_M_sl7_250m'] #carbon content data form 0cm to 200cm wmscarbon = ['ORCDRC_M_sl1_250m', 'ORCDRC_M_sl2_250m', 'ORCDRC_M_sl3_250m', 'ORCDRC_M_sl4_250m', 'ORCDRC_M_sl5_250m', 'ORCDRC_M_sl6_250m', 'ORCDRC_M_sl7_250m'] #other content data form 0cm to 200cm wmsother = ['BLDFIE_M_sl1_250m', 'BLDFIE_M_sl2_250m', 'BLDFIE_M_sl3_250m', 'BLDFIE_M_sl4_250m', 'BLDFIE_M_sl5_250m','BLDFIE_M_sl6_250m', 'BLDFIE_M_sl7_250m','CECSOL_M_sl1_250m', 'CECSOL_M_sl2_250m', 'CECSOL_M_sl3_250m', 'CECSOL_M_sl4_250m', 'CECSOL_M_sl5_250m', 'CECSOL_M_sl6_250m', 'CECSOL_M_sl7_250m'] #Organic matter data form 0cm to 200cm wmssoilOrganic = ['OCSTHA_M_sd1_250m','OCSTHA_M_sd2_250m','OCSTHA_M_sd3_250m','OCSTHA_M_sd4_250m','OCSTHA_M_sd5_250m','OCSTHA_M_sd6_250m']
Now extract the data with required extend as :
#import module from owslib.wms import WebMapService #set the wms service url for data extraction wms = WebMapService('http://data.isric.org/geoserver/sg250m/wcs') #loop the list of data you want to download for i in wmssoilOrganic: #assign the wms as image with projection 4326(WGS 84) bounding box(bbox) and format geotiff for raster or png, jped as required img = wms.getmap(layers=[i],srs='EPSG:4326',bbox=(80, 26, 90, 31),size=(10000, 10000),format='image/geotiff',transparent=True) #set the location to save data location = "/wmsLayers/"+i+".tif" #write the file out = open(location, 'wb') out.write(img.read()) out.close()
Soil data will be downloaded to the location you have set with the name as extracted for the Soil grid.